package org.mspring.mlog.action.blog;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.mspring.nbee.common.utils.CollectionUtils;
import org.mspring.nbee.common.utils.RequestUtils;
import org.mspring.nbee.web.Action;
import org.mspring.nbee.web.support.WebContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 畅言
 *
 * @author Gao Youbo
 * @since 2015-01-26 13:49
 */
@Action("blogChangyanAction")
public class ChangyanAction {
    private static final Logger LOG = LoggerFactory.getLogger(ChangyanAction.class);

    /**
     * 畅言评论回推
     *
     * @param context
     */
    @RequestMapping("/changyan/callback")
    public void callback(WebContext context) {
        String data = RequestUtils.getParam(context.getRequest(), "data");
        LOG.info("畅言评论回推...{}", data);
        if (StringUtils.isBlank(data)) {
            context.renderJsonResult(false);
        }
        JSONObject object = new JSONObject();
        JSONArray commentList = object.getJSONArray("comments");
        if (CollectionUtils.isEmpty(commentList)) {
            context.renderJsonResult(false);
        }
        long articleId = object.getLongValue("sourceid");
        for (int i = 0; i < commentList.size(); i++) {
            JSONObject item = commentList.getJSONObject(i);
        }
    }
}
